
import WorkAPI from '../api/Work.js';

export const Work={
   state:{
      editWorkStatus:-1,     //插入状态 0失败  1成功  -1不改变
      workinfo:[],
   },
   mutations:{
      setEditWorkStatus(state,status){
          state.editWorkStatus=status;
      },
      setWorkInfo(state,info){
          state.workinfo=info;
      }
   },
   actions:{
      //插入Work
      editWork(context,data){
          WorkAPI.editWork(data).then(function(response){
              context.commit('setEditWorkStatus',response.data.code);
          })
      },
      //获取详情
      loadWorkInfo(context,data){
          WorkAPI.getWorkInfo(data).then(function(response){
              if(response.data.code==1){
                  context.commit('setWorkInfo',response.data.info);
              }
          })
      }
   },
   getters:{
      getEditWorkStatus:state=>{
          return state.editWorkStatus;
      },
      getWorkInfo:state => {
          return state.workinfo;
      }
   }
}
